﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;

namespace DAO
{
    public class PhieuThueDAO
    {
        public static DataClasses1DataContext data = new DataClasses1DataContext();

        public static List<PhieuThue> LayDanhSachPhieuThue()
        {
            try
            {
                var query = from phieuthue in data.PhieuThues select phieuthue;
                List<PhieuThue> list = new List<PhieuThue>();
                foreach (PhieuThue phieu in query)
                {
                    list.Add(phieu);
                }
                return list;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static bool LapPhieuThue(PhieuThue phieu)
        {
            try
            {
                data.PhieuThues.InsertOnSubmit(phieu);
                data.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
